<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "exact",
		elements : "Post_content",
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		plugins : "safari,save,advhr,advimage,advlink,emotions,iespell,preview,searchreplace,contextmenu,paste,fullscreen,noneditable,visualchars,xhtmlxtras,inlinepopups",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,hr,removeformat,charmap,emotions,iespell,|,preview,fullscreen",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "<?php echo Yii::app()->request->baseUrl;?>/css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
    file_browser_callback : "tinyBrowser",

	});

</script>

<div class="form">
<?php echo CHtml::beginForm(); ?>

<?php echo CHtml::errorSummary($post); ?>

<div class="row">
<?php echo CHtml::activeLabel($post,'title'); ?>
<?php echo CHtml::activeTextField($post,'title',array('size'=>65,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($post,'content'); ?>
<?php echo CHtml::activeTextArea($post,'content',array('rows'=>20, 'cols'=>50)); ?>
<p class="hint">
You may use <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown syntax</a>.
</p>
</div>
<div class="row">
<?php echo CHtml::activeLabel($post,'tags'); ?>
<?php echo CHtml::activeTextField($post,'tags',array('size'=>65)); ?>
<p class="hint">
Separate different tags with commas.
</p>
</div>
<div class="row">
<?php echo CHtml::activeLabel($post,'status'); ?>
<?php echo CHtml::activeDropDownList($post,'status',Post::model()->statusOptions); ?>
</div>

<div class="row action">
<?php echo CHtml::submitButton($update ? 'Guardar' : 'Guardar', array('name'=>'submitPost')); ?>

<?php echo CHtml::submitButton('Vista previa',array('name'=>'previewPost')); ?>
</div>

<?php echo CHtml::endForm(); ?>
</div><!-- form -->

<?php if(isset($_POST['previewPost']) && !$post->hasErrors()): ?>
<h3>Preview</h3>
<div class="post">
  <div class="title"><?php echo CHtml::encode($post->title); ?></div>
  <div class="author">posted by <?php echo Yii::app()->user->name . ' on ' . date('F j, Y',$post->createTime); ?></div>
  <div class="content"><?php echo $post->contentDisplay; ?></div>
</div><!-- post preview -->
<?php endif; ?>